<template>
  <div class="rights">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-table :data="rightsData" border style="width: 100%" stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template v-slot="scope">
            <el-tag :type="levelTags[scope.row.level].type">{{levelTags[scope.row.level].name}}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      rightsData: [],
      levelTags: [
        { name: '一级', type: '' },
        { name: '二级', type: 'success' },
        { name: '三级', type: 'warning' }
      ]
    }
  }, // 在created生命周期，或mounted生命周期里
  created() {
    this.getRoles()
  },
  methods: {
    async getRoles() {
      const { data: res } = await this.$axios.get('rights/list')
      this.rightsData = res.data
    }
  }
}
</script>

<style lang='less' scoped>
</style>
